rm(list = ls())

library(plyr)                           #version 1.8.4
library(dplyr)                          #version 0.7.6
library(pscl)                           #version 1.5.2
library(tidyr)                          #version 0.8.1
library(stargazer)                      #version 5.2.2

in_path <- ""

setwd(in_path)

## missing_coords==TRUE only
## voter data and weights not provided. we do not have approval to share this
voters <- read.table(
    paste0(in_path, "prep/arabic_usgeo_counts_20150901_to_20170213_with_voters.txt.gz"),
    sep="\t"
)
voters <- voters[,c("date","userid","user_lang","lang","arabic_name","voter","usa","state")]

voters$empty_state <- as.integer(voters$state=="")
voters$arabic_speaker <- with(voters, lang=="ar" | user_lang=="ar")
voters <- voters %>% select(-state, -lang, -user_lang, -usa)

## this data is restricted to id's in arabic_usgeo_counts_20150901_to_20170213.RData for this replication file
## this means that the code below will not run the models comparing samples
## sharing restrictions noted when analysis added during article revise and resubmit
load(
    paste0(
        in_path,
        "prep/arabic_sample_and_comparison_usgeo_text_20150901_to_20170213_sources.RData"
    )
)

## matched_sources <- merge(matched_sources, users, by.x="id", by.y="userid")
## matched_sources$matched_weight[matched_sources$arabic_name] <- 1
## matched_sources$id <- matched_sources$userid2

matched_sources$thesource <- sapply(strsplit(sapply(strsplit(matched_sources$source, ">"), "[", 2), "<"), "[", 1)
matched_sources$date <- as.Date(substr(matched_sources$.id, 1, 10), "%Y_%m_%d")

## matched_sources <- matched_sources[,c("id","thesource","date","arabic_name","matched","matched_weight")]
## ## other sources have small cells
## matched_sources$thesource[!(matched_sources$thesource %in% c("Instagram","Foursquare"))] <- "other"

## save(
##     matched_sources,
##     file="./data/arabic_sample_only_usgeo_20150901_to_20170213_sources.RData"
## )

## load(
##     file="./data/arabic_sample_only_usgeo_20150901_to_20170213_sources.RData"
## )

length(unique(subset(
    matched_sources,
    arabic_name & id %in% unique(subset(voters, voter==1)$userid) &
    date > "2015-10-30" & date < "2016-01-01"
    )$id))

length(unique(subset(matched_sources, arabic_name & date > "2015-10-30" & date < "2016-01-01")$id))

#### counts
####

## the poisson models will have warnings due to weights
## pdf("instagram_not_instagram_arabic_names_and_speakers.pdf", width=12, height=8)
par(mfrow=c(2,2))

#### Arabic name, arabic speaker, not from Instagram
arabic_speaker_not_instagram_all <- subset(
    matched_sources,
    arabic_name &
    thesource!="Instagram" &
    date > "2015-10-30" & date < "2016-01-01" &
    id %in% unique(subset(voters, arabic_speaker)$userid)
    )
arabic_speaker_not_instagram_all_agg <- arabic_speaker_not_instagram_all %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(count = mean(arabic_name)) %>%
    dplyr::summarise(count = sum(count)) %>%
    ungroup()

arabic_speaker_not_instagram_matched_voter <- subset(
    matched_sources,
    matched &
    thesource!="Instagram" &
    date > "2015-10-30" & date < "2016-01-01"
    )
arabic_speaker_not_instagram_matched_voter_agg <- arabic_speaker_not_instagram_matched_voter %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(matched_weight = mean(matched_weight)) %>%
    dplyr::summarise(count = sum(matched_weight)) %>%
    ungroup()

mod_poisson_not_instagram_arabic_speaker <- glm(
    count ~ arabic_name * I(date > "2015-12-02"),
    data = rbind(
        arabic_speaker_not_instagram_all_agg,
        arabic_speaker_not_instagram_matched_voter_agg
    ), family="poisson"
)

count_diff <- mean(
    subset(arabic_speaker_not_instagram_all_agg, date <  "2015-12-07")$count
) / mean(
        subset(arabic_speaker_not_instagram_matched_voter_agg, date <  "2015-12-07")$count
    )

with(
    arabic_speaker_not_instagram_all_agg,
    plot(
        as.Date(date), count, type="l",
        main="Geotags not from Instagram -- Arabic names, speakers\nNovember and December 2015",
        xlab="Date", ylab="Number of users (weighted)",
        bty="n", lwd=3, cex.lab=1.3
         )
    )
with(
    arabic_speaker_not_instagram_matched_voter_agg,
    lines(
        as.Date(date), arabic_speaker_not_instagram_matched_voter_agg$count * count_diff,
        type="l", col="blue", lwd=3
        )
    )
legend(
    "topright",
    legend=c(
        "Arabic names, Arabic language",
        paste0("Matched control group (weighted)\nmultiplied by ", round(count_diff, 2))
    ),
    col=c("black","blue"), lwd=3, bty="n", cex=0.6
    )
abline(v=as.Date("2015-12-02"), col="red")
abline(v=as.Date("2015-12-07"), col="red")




#### Arabic name, arabic speaker, from Instagram
arabic_speaker_instagram_all <- subset(
    matched_sources,
    arabic_name &
    thesource=="Instagram" &
    date > "2015-10-30" & date < "2016-01-01" &
    id %in% unique(subset(voters, arabic_speaker)$userid)
    )
arabic_speaker_instagram_all_agg <- arabic_speaker_instagram_all %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(count = mean(arabic_name)) %>%
    dplyr::summarise(count = sum(count)) %>%
    ungroup()

arabic_speaker_instagram_matched_voter <- subset(
    matched_sources,
    matched &
    thesource=="Instagram" &
    date > "2015-10-30" & date < "2016-01-01"
    )
arabic_speaker_instagram_matched_voter_agg <- arabic_speaker_instagram_matched_voter %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(matched_weight = mean(matched_weight)) %>%
    dplyr::summarise(count = sum(matched_weight)) %>%
    ungroup()

mod_poisson_instagram_arabic_speaker <- glm(
    count ~ arabic_name * I(date > "2015-12-02"),
    data = rbind(
        arabic_speaker_instagram_all_agg,
        arabic_speaker_instagram_matched_voter_agg
    ), family="poisson"
)

count_diff <- mean(
    subset(arabic_speaker_instagram_all_agg, date <  "2015-12-07")$count
) / mean(
        subset(arabic_speaker_instagram_matched_voter_agg, date <  "2015-12-07")$count
    )

with(
    arabic_speaker_instagram_all_agg,
    plot(
        as.Date(date), count, type="l",
        main="Geotags from Instagram -- Arabic names, speakers\nNovember and December 2015",
        xlab="Date", ylab="Number of users (weighted)",
        bty="n", lwd=3, cex.lab=1.3
         )
    )
with(
    arabic_speaker_instagram_matched_voter_agg,
    lines(
        as.Date(date), arabic_speaker_instagram_matched_voter_agg$count * count_diff,
        type="l", col="blue", lwd=3
        )
    )
legend(
    "topright",
    legend=c(
        "Arabic names, Arabic language",
        paste0("Matched control group (weighted)\nmultiplied by ", round(count_diff, 2))
    ),
    col=c("black","blue"), lwd=3, bty="n", cex=0.6
    )
abline(v=as.Date("2015-12-02"), col="red")
abline(v=as.Date("2015-12-07"), col="red")
## dev.off()




## pdf("instagram_not_instgram_arabic_names.pdf", width=12, height=4)
## par(mfrow=c(1,2))

#### Arabic name, not from Instagram
arabic_name_not_instagram_all <- subset(
    matched_sources,
    arabic_name &
    thesource!="Instagram" &
    date > "2015-10-30" & date < "2016-01-01"
    )
arabic_name_not_instagram_all_agg <- arabic_name_not_instagram_all %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(count = mean(arabic_name)) %>%
    dplyr::summarise(count = sum(count)) %>%
    ungroup()

arabic_name_not_instagram_matched_voter <- subset(
    matched_sources,
    matched &
    thesource!="Instagram" &
    date > "2015-10-30" & date < "2016-01-01"
    )
arabic_name_not_instagram_matched_voter_agg <- arabic_name_not_instagram_matched_voter %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(matched_weight = mean(matched_weight)) %>%
    dplyr::summarise(count = sum(matched_weight)) %>%
    ungroup()

mod_poisson_not_instagram_arabic_name <- glm(
    count ~ arabic_name * I(date > "2015-12-02"),
    data = rbind(
        arabic_name_not_instagram_all_agg,
        arabic_name_not_instagram_matched_voter_agg),
    family="poisson"
)


count_diff <- mean(
    subset(arabic_name_not_instagram_all_agg, date <  "2015-12-07")$count
) / mean(
        subset(arabic_name_not_instagram_matched_voter_agg, date <  "2015-12-07")$count
    )

with(
    arabic_name_not_instagram_all_agg,
    plot(
        as.Date(date), count, type="l",
        main="Geotags not from Instagram -- Arabic names\nNovember and December 2015",
        xlab="Date", ylab="Number of users (weighted)",
        bty="n", lwd=3, cex.lab=1.3,
        ylim=c(20, 65)
         )
    )
with(
    arabic_name_not_instagram_matched_voter_agg,
    lines(
        as.Date(date), arabic_name_not_instagram_matched_voter_agg$count * count_diff,
        type="l", col="blue", lwd=3
        )
    )
legend(
    "topright",
    legend=c(
        "Arabic names, Arabic language",
        paste0("Matched control group (weighted)\nmultiplied by ", round(count_diff, 2))
    ),
    col=c("black","blue"), lwd=3, bty="n", cex=0.6
    )
abline(v=as.Date("2015-12-02"), col="red")
abline(v=as.Date("2015-12-07"), col="red")




#### Arabic name, from Instagram
arabic_name_instagram_all <- subset(
    matched_sources,
    arabic_name &
    thesource=="Instagram" &
    date > "2015-10-30" & date < "2016-01-01"
    )
arabic_name_instagram_all_agg <- arabic_name_instagram_all %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(count = mean(arabic_name)) %>%
    dplyr::summarise(count = sum(count)) %>%
    ungroup()

arabic_name_instagram_matched_voter <- subset(
    matched_sources,
    matched &
    thesource=="Instagram" &
    date > "2015-10-30" & date < "2016-01-01"
    )
arabic_name_instagram_matched_voter_agg <- arabic_name_instagram_matched_voter %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(matched_weight = mean(matched_weight)) %>%
    dplyr::summarise(count = sum(matched_weight)) %>%
    ungroup()

mod_poisson_instagram_arabic_name <- glm(
    count ~ arabic_name * I(date > "2015-12-02"),
    data = rbind(
        arabic_name_instagram_all_agg,
        arabic_name_instagram_matched_voter_agg),
    family="poisson"
)

count_diff <- mean(
    subset(arabic_name_instagram_all_agg, date <  "2015-12-07")$count
) /
    mean(
        subset(arabic_name_instagram_matched_voter_agg, date <  "2015-12-07")$count
    )

with(
    arabic_name_instagram_all_agg,
    plot(
        as.Date(date), count, type="l",
        main="Geotags from Instagram -- Arabic names\nNovember and December 2015",
        xlab="Date", ylab="Number of users (weighted)",
        bty="n", lwd=3, cex.lab=1.3, ylim=c(55, 140)
         )
    )
with(
    arabic_name_instagram_matched_voter_agg,
    lines(
        as.Date(date), arabic_name_instagram_matched_voter_agg$count * count_diff,
        type="l", col="blue", lwd=3
        )
    )
legend(
    "topright",
    legend=c(
        "Arabic names",
        paste0(
            "Matched control group (weighted)\nmultiplied by ",
            round(count_diff, 2)
        )
    ),
    col=c("black","blue"), lwd=3, bty="n", cex=0.6
    )
abline(v=as.Date("2015-12-02"), col="red")
abline(v=as.Date("2015-12-07"), col="red")
## dev.off()


#### Arabic name, voters, all sources
instagram_all <- subset(
    matched_sources,
    arabic_name &
    date > "2015-10-30" & date < "2016-01-01" &
    id %in% unique(subset(voters, voter==1)$userid)
    )
instagram_all_agg <- instagram_all %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(count = mean(arabic_name)) %>%
    dplyr::summarise(count = sum(count)) %>%
    ungroup()

instagram_matched_voter <- subset(
    matched_sources,
    matched &
    date > "2015-10-30" & date < "2016-01-01"
    )
instagram_matched_voter_agg <- instagram_matched_voter %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(matched_weight = mean(matched_weight)) %>%
    dplyr::summarise(count = sum(matched_weight)) %>%
    ungroup()

mod_poisson_all_matched_voter <- glm(
    count ~ arabic_name * I(date > "2015-12-02"),
    data = rbind(instagram_all_agg, instagram_matched_voter_agg),
    family="poisson"
)



not_instagram_all <- subset(
    matched_sources,
    arabic_name &
    date > "2015-10-30" & date < "2016-01-01" &
    id %in% unique(subset(voters, voter==1)$userid)
    )
not_instagram_all_agg <- not_instagram_all %>%
    group_by(date, arabic_name, id) %>%
    dplyr::summarise(count = mean(arabic_name)) %>%
    dplyr::summarise(count = sum(count)) %>%
    ungroup()


stargazer(
    mod_poisson_not_instagram_arabic_speaker,
    mod_poisson_instagram_arabic_speaker,
    mod_poisson_not_instagram_arabic_name,
    mod_poisson_instagram_arabic_name,
    mod_poisson_all_matched_voter,
    type="text", report=('vcp'), omit.table.layout="n", digits=2
    )




#### any activity
####

## Arabic name, voters, all sources
instagram_all <- subset(
    matched_sources,
    id %in% unique(subset(voters, voter==1)$userid)
    & arabic_name
    & date > "2015-10-30" & date < "2016-01-01"
)
instagram_all_agg <- instagram_all %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(count = n_distinct(date)) %>% ungroup() %>%
    mutate(weight = arabic_name)

instagram_matched_voter <- subset(
    matched_sources,
    matched
    & date > "2015-10-30" & date < "2016-01-01"
)
instagram_matched_voter_agg <- instagram_matched_voter %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(
               count = n_distinct(date),
               matched_weight = mean(matched_weight) #grouped by userid, should be constant
           ) %>% ungroup() %>%
    mutate(weight = matched_weight) %>% dplyr::select(-matched_weight)

instagram_agg <- rbind(                 #fill before/after for model
    instagram_all_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=T),
    instagram_matched_voter_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=F)
    )

instagram_agg <- merge(
    instagram_agg %>% dplyr::select(-weight),
    instagram_agg %>% group_by(id) %>% dplyr::summarise(weight = mean(weight, na.rm=T)),
    by="id"
    )

mod_binom_matched_voter_all <- glm(
    count>0 ~ arabic_name * pre_post,
    data = subset(instagram_agg, weight > 0),
    family=binomial(link=log),
    weight=weight
)
mod_quasi_matched_voter_all <- glm(
    count > 0 ~ arabic_name * pre_post,
    data = subset(instagram_agg, weight > 0),
    family="quasipoisson",
    weight=weight
)



## Arabic name and speaker, from Instagram
arabic_speaker_instagram_all <- subset(
    matched_sources,
    thesource=="Instagram" &
    id %in% unique(subset(voters, arabic_speaker)$userid)
    & arabic_name
    & date > "2015-10-30" & date < "2016-01-01"
)
arabic_speaker_instagram_all_agg <- arabic_speaker_instagram_all %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(count = n_distinct(date)) %>% ungroup() %>%
    mutate(weight = arabic_name)

arabic_speaker_instagram_matched_voter <- subset(
    matched_sources,
    thesource=="Instagram"
    & matched
    & date > "2015-10-30" & date < "2016-01-01"
)
arabic_speaker_instagram_matched_voter_agg <- arabic_speaker_instagram_matched_voter %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(count = n_distinct(date), matched_weight = mean(matched_weight)) %>% ungroup() %>%
    mutate(weight = matched_weight) %>% dplyr::select(-matched_weight)

arabic_speaker_instagram_agg <- rbind(
    arabic_speaker_instagram_all_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=T),
    arabic_speaker_instagram_matched_voter_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=F)
    )

arabic_speaker_instagram_agg <- merge(
    arabic_speaker_instagram_agg %>% dplyr::select(-weight),
    arabic_speaker_instagram_agg %>% group_by(id) %>% dplyr::summarise(weight = mean(weight, na.rm=T)),
    by="id"
    )

mod_binom_speaker_instagram <- glm(
    count>0 ~ arabic_name * pre_post,
    data = subset(arabic_speaker_instagram_agg, weight > 0),
    family=binomial(link=log),
    weight=weight
)
mod_quasi_speaker_instagram <- glm(
    count > 0 ~ arabic_name * pre_post,
    data = subset(arabic_speaker_instagram_agg, weight > 0),
    family="quasipoisson",
    weight=weight
)





## Arabic name, from Instagram
arabic_name_instagram_all <- subset(
    matched_sources,
    thesource=="Instagram"
    & arabic_name
    & date > "2015-10-30" & date < "2016-01-01"
)
arabic_name_instagram_all_agg <- arabic_name_instagram_all %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(count = n_distinct(date)) %>% ungroup() %>%
    mutate(weight = arabic_name)

arabic_name_instagram_matched_voter <- subset(
    matched_sources,
    thesource=="Instagram" &
    matched
    & date > "2015-10-30" & date < "2016-01-01"
)
arabic_name_instagram_matched_voter_agg <- arabic_name_instagram_matched_voter %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(count = n_distinct(date), matched_weight = mean(matched_weight)) %>% ungroup() %>%
    mutate(weight = matched_weight) %>% dplyr::select(-matched_weight)

arabic_name_instagram_agg <- rbind(
    arabic_name_instagram_all_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=T),
    arabic_name_instagram_matched_voter_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=F)
    )

arabic_name_instagram_agg <- merge(
    arabic_name_instagram_agg %>% dplyr::select(-weight),
    arabic_name_instagram_agg %>% group_by(id) %>% dplyr::summarise(weight = mean(weight, na.rm=T)),
    by="id"
    )


mod_binom_name_instagram <- glm(
    count>0 ~ arabic_name * pre_post,
    data = subset(arabic_name_instagram_agg, weight > 0),
    family=binomial(link=log),
    weight=weight
)
mod_quasi_name_instagram <- glm(
    count > 0 ~ arabic_name * pre_post,
    data = subset(arabic_name_instagram_agg, weight > 0),
    family="quasipoisson",
    weight=weight
)







## Arabic name and speaker, not from Instagram
arabic_speaker_not_instagram_all <- subset(
    matched_sources,
    thesource!="Instagram"
    & id %in% unique(subset(voters, arabic_speaker)$userid)
    & arabic_name
    & date > "2015-10-30" & date < "2016-01-01"
)
arabic_speaker_not_instagram_all_agg <- arabic_speaker_not_instagram_all %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(count = n_distinct(date)) %>% ungroup() %>%
    mutate(weight = arabic_name)

arabic_speaker_not_instagram_matched_voter <- subset(
    matched_sources,
    thesource!="Instagram"
    & matched
    & date > "2015-10-30" & date < "2016-01-01"
)
arabic_speaker_not_instagram_matched_voter_agg <- arabic_speaker_not_instagram_matched_voter %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(count = n_distinct(date), matched_weight = mean(matched_weight)) %>% ungroup() %>%
    mutate(weight = matched_weight) %>% dplyr::select(-matched_weight)

arabic_speaker_not_instagram_agg <- rbind(
    arabic_speaker_not_instagram_all_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=T),
    arabic_speaker_not_instagram_matched_voter_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=F)
    )

arabic_speaker_not_instagram_agg <- merge(
    arabic_speaker_not_instagram_agg %>% dplyr::select(-weight),
    arabic_speaker_not_instagram_agg %>% group_by(id) %>% dplyr::summarise(weight = mean(weight, na.rm=T)),
    by="id"
    )

mod_binom_speaker_not_instagram <- glm(
    count>0 ~ arabic_name * pre_post,
    data = subset(arabic_speaker_not_instagram_agg, weight > 0),
    family=binomial(link=log),
    weight=weight
)
mod_quasi_speaker_not_instagram <- glm(
    count > 0 ~ arabic_name * pre_post,
    data = subset(arabic_speaker_not_instagram_agg, weight > 0),
    family="quasipoisson",
    weight=weight
)




## Arabic name, not from Instagram
arabic_name_not_instagram_all <- subset(
    matched_sources,
    thesource!="Instagram"
    & arabic_name
    & date > "2015-10-30" & date < "2016-01-01"
)
arabic_name_not_instagram_all_agg <- arabic_name_not_instagram_all %>% mutate(pre_post = date > "2015-12-02") %>% group_by(pre_post, arabic_name, id) %>% dplyr::summarise(count = n_distinct(date)) %>% ungroup() %>% mutate(weight = arabic_name)

arabic_name_not_instagram_matched_voter <- subset(matched_sources, thesource!="Instagram" & matched & date > "2015-10-30" & date < "2016-01-01")
arabic_name_not_instagram_matched_voter_agg <- arabic_name_not_instagram_matched_voter %>%
    mutate(pre_post = date > "2015-12-02") %>%
    group_by(pre_post, arabic_name, id) %>%
    dplyr::summarise(count = n_distinct(date), matched_weight = mean(matched_weight)) %>% ungroup() %>%
    mutate(weight = matched_weight) %>% dplyr::select(-matched_weight)

arabic_name_not_instagram_agg <- rbind(
    arabic_name_not_instagram_all_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=T),
    arabic_name_not_instagram_matched_voter_agg %>% complete(pre_post, id, fill=list(count=0)) %>% mutate(arabic_name=F)
    )

arabic_name_not_instagram_agg <- merge(
    arabic_name_not_instagram_agg %>% dplyr::select(-weight),
    arabic_name_not_instagram_agg %>% group_by(id) %>% dplyr::summarise(weight = mean(weight, na.rm=T)),
    by="id"
    )


mod_binom_name_not_instagram <- glm(
    count>0 ~ arabic_name * pre_post,
    data = subset(arabic_name_not_instagram_agg, weight > 0),
    family=binomial(link=log),
    weight=weight
)
mod_quasi_name_not_instagram <- glm(
    count > 0 ~ arabic_name * pre_post,
    data = subset(arabic_name_not_instagram_agg, weight > 0),
    family="quasipoisson",
    weight=weight
)

stargazer(
    mod_quasi_speaker_not_instagram,
    mod_quasi_speaker_instagram,
    mod_quasi_name_not_instagram,
    mod_quasi_name_instagram,
    mod_quasi_matched_voter_all,
    type="text", report=('vcp'), omit.table.layout="n",
    digits=2
    )

stargazer(
    mod_binom_speaker_not_instagram,
    mod_binom_speaker_instagram,
    mod_binom_name_not_instagram,
    mod_binom_name_instagram,
    mod_binom_matched_voter_all,
    type="text", report=('vcp'), omit.table.layout="n"
    )
